#!/bin/bash

# 定义备份目录和目标目录
backup_dir="/path/to/backup"
target_dir="/path/to/data"

# 备份数据
backup_data() {
    # 创建备份目录
    mkdir -p "$backup_dir"

    # 备份数据命令
    # 例如：cp -r "$target_dir" "$backup_dir"
    echo "备份数据到 $backup_dir"
}

# 清理过期备份
cleanup_backup() {
    # 清理过期备份的命令
    # 例如：find "$backup_dir" -mtime +7 -type f -delete
    echo "清理过期备份"
}

# 根据用户输入执行相应操作
read -p "请输入操作（backup/cleanup）: " action

case "$action" in
    "backup")
        backup_data
        ;;
    "cleanup")
        cleanup_backup
        ;;
    *)
        echo "无效的操作"
        ;;
esac
